pkgname=mongodb
pkgver=r4.1.6
pkgrel=0
arch=('x86_64')
url="https://www.mongodb.com/"
pkgdesc="A high-performance, open source, schema-free document-oriented database"
license=('AGPL3')
depends=()
makedepends_debian_11=(libcurl4-openssl-dev scons python3-pip python3-dev libssl-dev)
source=("https://github.com/mongodb/mongo.git")
sha256sums=('SKIP')

build() {
	local PIP=pip

	which pip2 >/dev/null && PIP=$(which pip2)

	cd "${srcdir}/mongo"
	git checkout -f r4.1.6

	# ImportError: 'module' object has no attribute 'check_specifier' on aliyun OS
	$PIP install setuptools --upgrade

	for i in $(seq 1 10)
	do
		$PIP install -i https://mirrors.aliyun.com/pypi/simple --user -r etc/pip/dev-requirements.txt && break
	done

	[ "$DISTRO" = "centos" -o "$DISTRO" = "aliyun" ] && {
		source $LKP_SRC/distro/centos
		install_gcc7
		build_opts="CC=/opt/rh/devtoolset-7/root/usr/bin/gcc CXX=/opt/rh/devtoolset-7/root/usr/bin/g++"
	}

	buildscripts/scons.py core --disable-warnings-as-errors -j $(nproc) $build_opts
}

package() {
	mkdir -p "${pkgdir}/lkp/benchmarks/${pkgname}/bin"
	cd "${srcdir}/mongo"
	cp mongo* "${pkgdir}/lkp/benchmarks/${pkgname}/bin"
}
